<template>
	<view class="auth-notice-box" v-if="status===233">
		<bs-navbar title='入会须知'></bs-navbar>
		<u-parse :html="content"></u-parse>
		<view class="btns">
			<u-button type="jz" ripple="" @click="handToForm">同意并申请入会</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgUrl: this.configImgUrl,
				status: null,
				content: ''
			};
		},
		onShow() {},
		async onLoad() {
			uni.showLoading({
				title: '加载中,请稍等..',
			})
			//获取入会须知
			let content = await this.$u.api.selectNotic()
			console.log(content, '入会须知')
			this.content = content[0].content
			//查询会员申报状态
			const userCode = this.cache.getCache('userCode')
			let selectMyVip = await this.$u.api.selectMyVip({
				page: 1,
				pageSize: 20,
				userCode: userCode,
			})
			console.log(selectMyVip, 'selectMyVipselectMyVip')
			if (selectMyVip.length === 0) {
				uni.hideLoading()
				this.status = 233
				//当前没有申报的会员
			} else {
				uni.hideLoading()
				//0审核中.1审核通过.2审核失败
				this.status = selectMyVip[0].status
				let declareId = selectMyVip[0].declareId
				let vipTypeId = selectMyVip[0].vipId
				let price = selectMyVip[0].price
				switch (this.status) {
					case '0': //审核中
						uni.redirectTo({
							url: '/pages/my/authVip/audit',
						})
						break;
					case '1': //审核通过
						uni.redirectTo({
							url: '/pages/my/authVip/passAudit?price=' + price + '&vipTypeId=' + vipTypeId
						})
						break;
					case '2': //审核失败
						uni.redirectTo({
							url: '/pages/my/authVip/notAudit?declareId=' + declareId + '&status=' + this.status + '&vipTypeId=' +
								vipTypeId
						})
						break;
					case '3': //待认证
						uni.redirectTo({
							url: '/pages/my/authVip/paySucceed?declareId=' + declareId + '&status=' + this.status + '&vipTypeId=' +
								vipTypeId
						})
						break;
					case '4': //认证成功
						uni.redirectTo({
							url: '/pages/my/authVip/paySucceed?declareId=' + declareId + '&status=' + this.status + '&vipTypeId=' +
								vipTypeId
						})
						break;
					default:
						break;
				}

			}
		},
		methods: {
			handToForm() {
				uni.navigateTo({
					url: '/pages/my/authVip/authForm'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.auth-notice-box {
		padding: 0 30rpx;

		.btns {
			width: 100%;
			position: fixed;
			left: 0;
			bottom: 0;
			padding: 20rpx;
			background: #FFFFFF;
			box-shadow: 0 0 26px 0 rgba(18, 27, 83, 0.07);
		}
	}
</style>
